package com.wyzz.hr.dao.impl;

import com.wyzz.hr.base.Status;
import com.wyzz.hr.dao.IStatusDAO;
import com.wyzz.hr.hibernate.impl.HibernateUtil;
import com.wyzz.hr.pojo.Statusconf;

import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Expression;

public class StatusDAOImpl extends HibernateUtil implements IStatusDAO, Status {

	public StatusDAOImpl() {
	}

	public List getStatusByTable(String tableName) {
		Criteria crite = getSession().createCriteria(
				com.wyzz.hr.pojo.Statusconf.class);
		crite.add(Expression.eq("id.statusconfTablename", tableName.trim()));
		return crite.list();
	}

	public Statusconf getStatusByName(String tableName, String statusName) {
		Criteria crite = getSession().createCriteria(
				com.wyzz.hr.pojo.Statusconf.class);
		crite.add(Expression.eq("id.statusconfTablename", tableName.trim()));
		crite.add(Expression.like("statusconfDesc", (new StringBuilder())
				.append("%").append(statusName).append("%").toString()));
		return (Statusconf) crite.uniqueResult();
	}

	public List getCompeplanStatusInRecruitplan(String tableName) {
		Criteria crite = getSession().createCriteria(
				com.wyzz.hr.pojo.Statusconf.class);
		crite.add(Expression.eq("id.statusconfTablename", tableName.trim()));
		return crite.list();
	}
}
